package com.ruoyi.web.controller.ies;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.ies.domain.SugStaff;
import com.ruoyi.ies.service.ISugStaffService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 员工反馈Controller
 * 
 * @author July
 * @date 2023-06-09
 */
@RestController
@RequestMapping("/ies/staff")
public class SugStaffController extends BaseController
{
    @Autowired
    private ISugStaffService sugStaffService;

    /**
     * 查询员工反馈列表
     */
    @PreAuthorize("@ss.hasPermi('ies:staff:list')")
    @GetMapping("/list")
    public TableDataInfo list(SugStaff sugStaff)
    {
        startPage();
        List<SugStaff> list = sugStaffService.selectSugStaffList(sugStaff);
        return getDataTable(list);
    }

    /**
     * 导出员工反馈列表
     */
    @PreAuthorize("@ss.hasPermi('ies:staff:export')")
    @Log(title = "员工反馈", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SugStaff sugStaff)
    {
        List<SugStaff> list = sugStaffService.selectSugStaffList(sugStaff);
        ExcelUtil<SugStaff> util = new ExcelUtil<SugStaff>(SugStaff.class);
        util.exportExcel(response, list, "员工反馈数据");
    }

    /**
     * 获取员工反馈详细信息
     */
    @PreAuthorize("@ss.hasPermi('ies:staff:query')")
    @GetMapping(value = "/{sugId}")
    public AjaxResult getInfo(@PathVariable("sugId") Long sugId)
    {
        return success(sugStaffService.selectSugStaffBySugId(sugId));
    }

    /**
     * 新增员工反馈
     */
    @PreAuthorize("@ss.hasPermi('ies:staff:add')")
    @Log(title = "员工反馈", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SugStaff sugStaff)
    {
        return toAjax(sugStaffService.insertSugStaff(sugStaff));
    }

    /**
     * 修改员工反馈
     */
    @PreAuthorize("@ss.hasPermi('ies:staff:edit')")
    @Log(title = "员工反馈", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SugStaff sugStaff)
    {
        return toAjax(sugStaffService.updateSugStaff(sugStaff));
    }

    /**
     * 删除员工反馈
     */
    @PreAuthorize("@ss.hasPermi('ies:staff:remove')")
    @Log(title = "员工反馈", businessType = BusinessType.DELETE)
	@DeleteMapping("/{sugIds}")
    public AjaxResult remove(@PathVariable Long[] sugIds)
    {
        return toAjax(sugStaffService.deleteSugStaffBySugIds(sugIds));
    }
}
